# -*- coding: utf-8 -*-
from advcam_physical_attack import attack
import os
class Fileparameters():
    def __init__(self):
        # 内容图像的路径
        self.content_image_path = './physical-attack-data/content/stop-sign/stop-sign.jpg'
        # 风格图像的文件夹
        self.style_image_path = './physical-attack-data/style/stop-sign/stop-snow-style.jpg'
        # 样式分割的路径
        self.content_seg_path = './physical-attack-data/content-mask'
        self.style_seg_path = './physical-attack-data/style-mask'
        # 背景图
        self.background_path = './physical-attack-data/background/traffic_bg'

        self.result_dir = 'Attack_Result'# 保存结果的文件夹

        self.targeted_attack = 1  # 1为目标攻击，0为非目标攻击
        self.target_label = 546  # 攻击目标的标签

        self.serial = ''# 生成图像结果的文件名
        self.max_iter = 4000 #最大迭代次数
        self.learning_rate = 1.0 #学习率
        self.save_iter = 50 #保存图像的迭代间隔
        self.content_weight = 5e0 # loss_c的权重
        self.style_weight = 1e2 # loss_s的权重
        self.smoothness_weight = 1e-3 # loss_m的权重
        self.attack_weight = 5e3 #loss_adv的权重
        self.true_label = None #content图像的真实标签
        self.cross_class = False #如果为 True，则在不同类之间应用照片风格转移攻击
        self.test_mode = 'all'
        self.target_size = (400, 400)
        self.model_input_size = (224, 224)



if __name__ == "__main__":
    args = Fileparameters()
    # 提取到风格图片的路径
    content_name = args.content_image_path.split('/')[-1]
    # 提取到分割图片的路径
    content_seg_name = content_name.split('.')[0] + '.jpg'
    args.content_seg_path = os.path.join(args.content_seg_path, content_name).replace("\\", "/")
    # 提取到分割图片的路径
    style_name = args.style_image_path.split('/')[-1]
    args.style_seg_path = os.path.join(args.style_seg_path, style_name)
    # 保存结果的路径
    result_path = os.path.join(args.result_dir, content_name.split('.')[0], str(args.target_label) + '_' + str(args.attack_weight)+'_'+ style_name.split('.')[0] )
    path_exist = os.path.exists(result_path)
    args.serial = result_path

    if not path_exist:
        os.makedirs(result_path)
    attack(args)

